import request from '@/utils/request'

// 注册接口
export const register = ({ username, password, repassword }) => {
  return request.post('/api/reg', { username, password, repassword })
}

// 登录接口
export const login = ({ username, password }) => {
  return request.post('/api/login', { username, password })
}

// 获取用户信息接口
export const getUserInfoService = () => request.get('/my/userinfo')

// 更新用户信息接口
export const updateUserInforService = ({ id, username, nickname, email, user_pic }) => {
  return request.put('/my/userinfo', { id, username, nickname, email, user_pic })
}

// 更新用户头像接口
export const updateUserAvatarService = (avatar) => {
  return request.patch('/my/update/avatar', { avatar })
}

// 更新密码
export const updateUserPasswordService = ({ old_pwd, new_pwd, re_pwd }) => {
  return request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
}